package com.zhaopin.springboot.web;

import com.zhaopin.springboot.config.Company;
import com.zhaopin.springboot.service.QuzmlService;
import com.zhaopin.springboot.service.VectorMain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @create 2021-04-19 16:18
 */
@RestController
public class IndexController {


    @Autowired
    private QuzmlService quzmlService;

    @Autowired
    private VectorMain vectorMain;

    @Value("${company.name}")
    private String companyName;

    @Value("${company.website}")
    private String webSite;

    @Autowired
    private Company company;


    /**
     * 返回结果值
     *
     * @param
     * @return
     */
    @RequestMapping(value = "quzml", method = {RequestMethod.GET, RequestMethod.POST})
    public String getQuzml(@RequestParam(value = "word", defaultValue = "销售经理") String word) {
        return quzmlService.getString(word);
    }


    /**
     * 返回结果值
     *
     * @param
     * @return
     */
    @RequestMapping(value = "wordList", method = {RequestMethod.GET, RequestMethod.POST})
    public List getWordList(@RequestParam(value = "word", defaultValue = "销售经理") String word) throws IOException {
        return vectorMain.getWordList(word);
    }


    /**
     * 初始case
     *
     * @param count
     * @return
     */
    @RequestMapping(value = "index", method = {RequestMethod.GET, RequestMethod.POST})
    public String getUserCount(@RequestParam(value = "count", defaultValue = "44") String count) {
        return "userCount is:" + count;
    }


    /**
     * 自定义配置获取
     *
     * @return
     */
    @RequestMapping(value = "customProperties")
    public Map getCustomProperties() {
        Map map = new HashMap();
        map.put("companyName", companyName);
        map.put("webSite", webSite);
        return map;
    }

    /**
     * 获取对象的结果
     *
     * @return
     */
    @RequestMapping(value = "getCompanyInfo")
    public String getCompanyInfo() {
        return "公司信息: " + company.toString();
    }

}
